package com.meixiang.adapter;

/**
 * Created by Administrator on 2016/5/6.
 */

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.meixiang.R;
import com.meixiang.activity.homes.insurance.InsuranceDetailsActivity;

import java.util.List;

/**
 * 推荐模块
 */
public class InsuranceRecommedAdapter extends RecyclerView.Adapter<InsuranceRecommedAdapter.MyViewHolder> {

    private List<String> data ;
    private Context context ;

    public InsuranceRecommedAdapter(Context context, List<String> data){
        this.data = data ;
        this.context = context ;
    }


    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        MyViewHolder myViewHolder = new MyViewHolder(LayoutInflater.from(context).inflate(R.layout.insurance_recommend_adapter_item, parent, false));
        return myViewHolder;
    }


    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
    }

    @Override
    public int getItemCount() {

        return data.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder {
        LinearLayout ll_parent;

        public MyViewHolder(View itemView) {
            super(itemView);
            ll_parent = (LinearLayout) itemView.findViewById(R.id.ll_parent);
            ll_parent.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    context.startActivity(new Intent(context,InsuranceDetailsActivity.class));
                }
            });
        }

    }
}